package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * @description:插入新的菜品
     * @return: void
     * @author: 梦龙
     * @time: 2023/11/28 19:23
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    /**
     * @description:根据分页查询数据
     * @return: com.github.pagehelper.Page<com.sky.vo.DishVO>
     * @author: 梦龙
     * @time: 2023/11/28 21:17
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    /**
     * @description:根据菜品id集合删除菜品数据
     * @return: void
     * @author: 梦龙
     * @time: 2023/11/29 11:10
     */
    void deleteByIds(List<Long> ids);


    /**
     * @description:修改菜品表的基本信息
     * @return: void
     * @author: 梦龙
     * @time: 2023/11/29 16:22
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where category_id = #{categoryId} ")
    List<DishVO> list(Long categoryId);


    @Select("select status from dish where id = #{dishId}")
    Integer getStatusById(Long dishId);

    List<Dish> listByDish(Dish dish);

    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
